﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using CreatureSoft.Hoot.Domain.DocumentManagent;

namespace CreatureSoft.Hoot.Data.Mapping
{
    public class FolderMap : EntityTypeConfiguration<Folder>
    {
        public FolderMap()
        {            
            this.HasKey(t => t.Id);
            
            this.Property(t => t.Id).HasColumnName("Id");
            
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.Name).IsRequired();

            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.Description).IsOptional();

            this.HasOptional(c => c.ParentFolder)
               .WithMany(c => c.SubFolders)
               .HasForeignKey(c => c.ParentFolderId);     
            
            

            this.ToTable("Folders");
        }
    }
}
